//
//  PKRequest.m
//  Learn
//
//  Created by apple on 2024/4/15.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "PKRequest.h"

@implementation PKRequest
+(void)request_getPkHomeDataResult:(void(^)(PkUserInfoModel *model,BOOL isDone))reslutBlock {
    NSMutableDictionary *param = [NSMutableDictionary dictionary];

    NSString *url = [NSString stringWithFormat:@"%@%@",BaseUrl,KM_API_getPkHome];
    [BaseRequest basePOST:url cache:NO autoHideLoading:NO parms:param result:^(id resultObject, NSError *error) {
        if (resultObject != nil && [resultObject[@"code"] integerValue] == 1) {
            PkUserInfoModel *model = [PkUserInfoModel mj_objectWithKeyValues:resultObject[@"data"]];
            reslutBlock(model,YES);
        } else {
            reslutBlock([PkUserInfoModel new],NO);
            [SVProgressHUD showErrorWithStatus:@"请求数据失败"];
        }
    }];
}
+(void)request_getPkMatchDataResult:(void(^)(PkMatchModel *model,BOOL isDone))reslutBlock {
    NSMutableDictionary *param = [NSMutableDictionary dictionary];

    NSString *url = [NSString stringWithFormat:@"%@%@",BaseUrl,KM_API_getPkMatchData];
    [BaseRequest baseGET:url cache:NO autoHideLoading:NO parms:param request:^(id resultObject, NSError *error) {
        if (resultObject != nil && [resultObject[@"code"] integerValue] == 1) {
            PkMatchModel *model = [PkMatchModel mj_objectWithKeyValues:resultObject[@"data"]];
            reslutBlock(model,YES);
        } else {
            reslutBlock([PkMatchModel new],NO);
            [SVProgressHUD showErrorWithStatus:@"请求数据失败"];
        }
    }];
}

+(void)request_postSavePkResultType:(NSString *)type reslut:(void(^)(BOOL isRequest))resultBlock {
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setValue:type forKey:@"type"];
    NSString *url = [NSString stringWithFormat:@"%@%@",BaseUrl,KM_API_postSavePkResult];
    [BaseRequest basePOST:url cache:NO autoHideLoading:NO parms:param result:^(id resultObject, NSError *error) {
        if (resultObject != nil && [resultObject[@"code"] integerValue] == 1) {
            resultBlock(YES);
        } else {
            resultBlock(NO);
        }
    }];
}

@end
